#ifndef INFODOWNLOADER_H
#define INFODOWNLOADER_H

#include <QObject>
#include <QNetworkReply>
#include <QDomDocument>
#include "songinfo.h"

class InfoDownloader : public QObject {
	Q_OBJECT;
public:
	InfoDownloader(QObject* parent);
	void startFetchingSongInfo();
	void startFetchingLyrics();
	SongInfo getSongInfo() { return songInfo; }
signals:
	void nextSongAvailable();
	void songInfoReady();
	void coverImageReady(QPixmap);
	void lyricsReady(QString);
private slots:
	void gotLyrics(QNetworkReply* reply);
	void gotSongInfo(QNetworkReply* reply);
	void gotCover(QNetworkReply* reply);
private:
	QString getElementText(QDomDocument& doc, const char* tagName);
	SongInfo songInfo;
	QNetworkAccessManager* lyricsDownloader;
	QNetworkAccessManager* infoDownloader;
	QNetworkAccessManager* coverDownloader;
};

#endif
